<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ page import="View.*" %>   
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/index.css" />
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
	<div id="header">
		<div id="title"><h1><a href="/webshop/index.jsp">ToWa webshop</a></h1></div>
		<div id="login">
		<%
		UserView user = (UserView) request.getSession().getAttribute("user");
		if(user == null){
		%>
		<form name="notLoggedInForm" action="/webshop/user/login" method="post">
			<table>
				<tr>
					<td>Username:</td>
					<td colspan="2"><input type="text" name="username" /></td>
					<td><!-- Empty cell --></td>
				</tr>
				<tr>
					<td>Password:</td>
					<td colspan="2"><input type="password" name="password" /></td>
					<td><!-- Empty cell --></td>
				</tr>
				<tr>
					<td><!-- Empty cell --></td>
					<td><input type="submit" value="login" /></td>
					<td><input type="button" value="register" onclick="location.href='/webshop/user/register.jsp'" /></td>
				</tr>
			</table>
			<input type="hidden" name="hidden" value="1" />
		</form>
		<%
		}else{
		%>
			<form name="loggedInForm" action="${pageContext.request.contextPath}/user/login" method="post">
				<table>
					<tr>
						<td colspan="2">Hello <%=user.getUsername()%>!</td>
					</tr>
					<tr>
						<td><a href="/webshop/user/profile.jsp">Profile</a></td>
						<td><input type="submit" value="Log Out" name="logout" /></td>
					</tr>
				</table>
				<input type="hidden" name="hidden" value="-1" />
			</form>
		<%
		}
		%>
		</div>
	</div>
</body>
</html>